home *** CD-ROM | disk | FTP | other *** search
- Path: news.infinet.com!cedwards
- From: cedwards@infinet.com (Chad Edwards)
- Newsgroups: comp.lang.c++
- Subject: Re: Using cin like sscanf()?
- Date: 4 Mar 1996 23:34:40 GMT
- Organization: InfiNet
- Message-ID: <4hfumg$np4@news1.infinet.com>
- References: <4gnudd$dd4@daily-planet.nodak.edu>
- NNTP-Posting-Host: 206.103.240.10
- X-Newsreader: TIN [version 1.2 PL2]
-
- Jeffro (ishaq@plains.nodak.edu) wrote:
- : greetings! I've always wondered if this is possible. Well, I'm sure
- : it's possible, but how is it done? Say I input a string into string:
-
- : char string[] = "This is a character string.";
- : char buffer[24];
-
- : How can I tell cin to read from string instead of stdin so I can do
- : soemthing like this:
-
- : //cin.read_from(string)
- : while (cin >> buffer) cout << buffer; //Outputs string
- : //cin.read_from(stdin)
-
- : This should be similar to:
-
- : while (sscanf(string, "%s", &buffer)) cout << buffer;
-
- : Any ideas?
- : Thanks!
- : -jeff
- : --
- : .,;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.
- : - Jeff Ishaq ishaq@plains.nodak.edu Computer Science major -
- : - at North Dakota State University in Fargo, ND. Drop me a line, eh? -
- : .,;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.
- : - better-than-average Phish songs: Chalk Dust Torture, You Enjoy Myself,
- : - David Bowie, Mound, Split Open and Melt, My Friend (has got a knife),
- : - Fire Up The Ganga (live, of course), Contact
-
- Assuming I understand what you want to do correctly:
-
- #include <iostream.h>
-
- void main()
- {
- char stringOne[256];
-
- cout << "Enter a string: ";
- cin.get (stringOne,256);
- cout << stringOne: " << stringOne << end1;
-
- }
-
- --
-
-
- ______________________________________________________________________________
- A SIG? What the heck is a Sig? Something you smoke?
- http://www.infinet.com/~cedwards
- ______________________________________________________________________________
-
-